#include <stdio.h>

int fun(int m, int n)
{
    if (n != 0)
        return m * fun(m, n - 1);
    else
    {
        return 1;
    }
}
int main()
{
    int i = 0;
    for (i = 1; i<100000; i++)
    {
        int tmp = i;
        int n = 0;
        while (tmp)
        {
            tmp = tmp / 10;
            n++;
        }
        int sum = 0;
        tmp = i;
        while (tmp)
        {
            int m = tmp % 10;
        int res = fun(m, n);
            tmp /= 10;
            sum += res;
        }
        if (sum == i)
            printf("%d ", i);
    }
}

